package cn.edu.seu.ssny.entity;

import cn.edu.seu.ssny.entity.Device;
import cn.edu.seu.ssny.entity.support.BaseEntity;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Set;

@Getter
@Setter

/**
 * 设备分类表
 */
@Entity
@Table(name = "tb_device_category")
public class DeviceCategory extends BaseEntity {


    /**
     * id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", nullable = false)
    private Integer id;
    /**
     * 名称
     */
    private String name;

    @OneToMany(fetch = FetchType.EAGER, targetEntity = Device.class, mappedBy="category")
    @JSONField(serialize = false)
    @OrderBy(value = "name")
    private List<Device> devices;

    @ManyToOne(fetch = FetchType.LAZY, targetEntity = Project.class)
    @JoinColumn(name = "project_id", referencedColumnName = "id")
    private Project project;
}
